/**
 * Description:
 * Class Name:ClientThread
 * Date:2022/5/24 13:46
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第17章_网络编程._17_3_基于TCP协议的网络编程._17_3_5_记录用户信息;

import java.io.BufferedReader;
import java.io.IOException;

public class ClientThread extends Thread{
    // 该客户端线程负责处理的输入流
    BufferedReader br = null;
    // 使用一个网络输入流来创建客户端线程
    public ClientThread(BufferedReader br){
        this.br = br;
    }

    @Override
    public void run() {
        try {
            String line = null;
            // 不断地从输入流中读取数据，并将这些数据打印输出
            while ((line = br.readLine()) != null){
                System.out.println(line);
            }
        }
        catch (IOException ex){
            ex.printStackTrace();
        }
        finally {
            try {
                if (br != null){
                    br.close();
                }
            }
            catch (IOException exception){
                exception.printStackTrace();
            }
        }
    }
}
